#include "TestScripting.hpp"
#include <string>
#include "SLB.hpp"
#include "ScriptComponent.hpp"
#include "ScriptGameObject.hpp"
#include "ScriptSystem.hpp"

class MainLoop : public SLB::Script {
public:

	void Update(float dt) {
		lua_State *L = getState();
		// prepare a call object
		//(C::*func)(K,V)
		//SLB::LuaCall<void(float)> call(L,"System:Update");
		SLB::LuaCall<void(float)> call(L,"Update");
		// perform the call with the parameters
		call(dt);
	}


};

void TestScripting::Initialize() {
	
	ScriptGameObject::SetWorld(&gameWorld);
	ScriptSystem::SetWorld(&gameWorld);

	ScriptComponent::InitScripting();
	ScriptGameObject::InitScripting();
	ScriptSystem::InitScripting();
	

	MainLoop s;

	try
	{
		s.doFile("D:/Jeppes/C++/Typhoon/Typhoon/VisualStudio/TestLua.lua");
		s.Update(0.5f);
	}
	catch (std::runtime_error e)
	{
		std::string error = e.what();
	}
	

}

void TestScripting::Update(float dt) {


}

void TestScripting::Render() {

}
